<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: blog_categories_list.php 11 2013-09-21 11:43:11Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 11 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2013-09-21 11:43:11 +0000 (Sat, 21 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

$status[] = array('id' => 0, 'text' => TABLE_FOOTER_STATUS_0);
$status[] = array('id' => 1, 'text' => TABLE_FOOTER_STATUS_1);
$status[] = array('id' => 2, 'text' => TABLE_FOOTER_STATUS_2);
$status[] = array('id' => 3, 'text' => TABLE_FOOTER_STATUS_3);

$listedit = array();
$listedit[] = array('id' => 0, 'text' => TABLE_HEADING_ACTION_EDIT_0);
$listedit[] = array('id' => 1, 'text' => TABLE_HEADING_ACTION_EDIT);

echo draw_form('leiste', FILENAME_BLOG, 'action=set', 'post', '');?>
	<script type="text/javascript">
		function loadItems(id, action, lng) {
			if ($('#all_items_'+id).length < 1) {
				showOverlay('.dataTable');
				xajax_blogAction(id, action, lng);
				$('#cat_'+id).html('<b>-</b>');
			} else {
				$('#all_items_'+id).fadeOut(500, function(){$(this).remove()});
				$('#cat_'+id).html('<b>+</b>');
			}
		}
	</script>
	<table width="100%" border="0" cellspacing="1" cellpadding="4" class="dataTable">
		<tr class="dataTableHeadingRow">
			<th class="dataTableHeadingContent" width="5%" align="center"><input type="checkbox" onclick="javascript:checkboxes(this.checked);"></th>
			<th class="dataTableHeadingContent" width="80%" align="left"><?php echo TABLE_HEADING_TITLE;?></th>
			<th class="dataTableHeadingContent" width="5%"><?php echo TABLE_HEADING_NEWCATEGORIE_POSITION;?></th>
			<th class="dataTableHeadingContent" width="10%"><?php echo TABLE_HEADING_ACTION;?></th>
		</tr>
		<?php
		$i = 0;
		$categories = $db->db_query("SELECT
											categories_id, titel, status, position
			       						FROM
			       							".TABLE_BLOG_CATEGORIES."
        								WHERE
        									language_id = '".$_SESSION['languages_id']."'
        								ORDER BY
        									position ASC");
		if($categories->_numOfRows) {
			while(!$categories->EOF){
				$count_offline_items = $db->db_query("SELECT categories_id FROM ".TABLE_BLOG_ITEMS." WHERE categories_id = '".$categories->fields['categories_id']."' AND language_id = '".$_SESSION['languages_id']."' AND status = 0");
				$count_items = $db->db_query("SELECT categories_id FROM ".TABLE_BLOG_ITEMS." WHERE categories_id = '".$categories->fields['categories_id']."' AND language_id = '".$_SESSION['languages_id']."'");

			?>
				<tr id="blog_cat_<?php echo $categories->fields['categories_id']; ?>"<?php echo (($i%2==0) ? ' class="dataTableRow"' : '');?>>
					<td align="center" valign="top">
						<?php
							echo draw_selection_field('status[]', 'checkbox', $categories->fields['categories_id']);
						?></td>
					<td>
					<?php
						echo '<span id="cat_'. $categories->fields['categories_id'].'" class="cursor" onclick="loadItems('.$categories->fields['categories_id'].',\'items\','.$_SESSION['languages_id'].')"><b>+</b></span>
						'.($categories->fields['status'] == 2 ? '<b>'.$categories->fields['titel'].'</b>' : '<span style="color:#b20000">'.$categories->fields['titel'].' - Offline</span>').'<br />';
						echo '<em style="font-size:85%; margin-left: 20px">'.TABLE_HEADING_BLOG_TOPIC . $count_items->_numOfRows.', '.TABLE_HEADING_BLOG_TOPIC_OFF . $count_offline_items->_numOfRows.'</em>';
					?>
					</td>
					<td align="center">
						<?php
							$field_position = $categories->fields['position'];
							echo $field_position;
						?>
					</td>
					<td align="center"><nobr>
						<a href="<?php echo href_link(FILENAME_BLOG,'action=new_item&'.getmenuID('blog').'&cat='.$categories->fields['categories_id']);?>">
							<?php echo image(DIR_WS_ICONS . 'document--plus.png', 'neuen Beitrag verfassen');?>
						</a>&nbsp;&nbsp;
						<a href="<?php echo href_link(FILENAME_BLOG,'action=showitems&'.getmenuID('blog').'&cat='.$categories->fields['categories_id']);?>">
							<?php echo image(DIR_WS_ICONS . 'go.gif', 'In diese Kategorie wechseln');?>
						</a>&nbsp;&nbsp;
						<a href="<?php echo href_link(FILENAME_BLOG,'action=editcategories&'.getmenuID('blog').'&cat='.$categories->fields['categories_id']);?>">
							<?php echo image(DIR_WS_ICONS . 'edit.gif', TABLE_HEADING_ACTION_EDIT);?>
						</a></nobr>
					</td>
				</tr>
				<?php
				$i++;
				$categories->MoveNext();
			}
			
		} else {
			echo '<tr><td colspan="4" valign="center" align="center"><b>Derzeit sind keine Kategorien vorhanden.</b></td></tr>';
		}

		?>
	</table>
	<br />
	<table width="100%" border="0" cellspacing="0" cellpadding="3">
		<tr>
			<td width="70" align="center"><?php echo TABLE_FOOTER_STATUS;?>
			<td width="70" align="center"><?php echo draw_pull_down_menu('set_cat_status', $status, '', 'style="width:100px;"');?></td>
			<td width="50" align="center"><?php echo '<button type="submit" class="button">Status &auml;ndern</button>';?></td>
			<td>&nbsp;</td>
		</tr>
	</table>
</form>